﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CrankShaftAnalysisSystem
{
    public class EastenGauge : ModbusProxy
    {
        public double[] ChannelData { get; private set; } = new double[5];
        public EastenGauge(string ip, int port):base(ip,port)
        {
            RegisterAdress = 0x2000;
            RegisterLength = 10;
            OnGetHoldingRegisters += EastenGauge_OnGetHoldingRegisters;
        }

        private void EastenGauge_OnGetHoldingRegisters(ushort[] regs)
        {
            int[] chs = new int[regs.Length / 2];
            for (int i = 0; i < chs.Length; i++)
            {
                chs[i] = (regs[2 * i] << 16) + regs[2 * i + 1];
                ChannelData[i] = chs[i] / 1000.0;
            }
        }
    }
}
